package com.xls.box2023.jifen;

import com.lzz.bottomencapsulation.net.RequestCallBack;
import com.lzz.bottomencapsulation.net.RequestCallBackTwo;
import com.lzz.bottomencapsulation.net.RetrofitBase;
import com.xls.box2023.BoxAppLication;
import com.xls.box2023.entity.DuiHuanJiBiInfoEntity;
import com.xls.box2023.entity.JiFenMingXiEntity;
import com.xls.box2023.entity.UserEntity;
import com.xls.box2023.network.RequestManager;
import com.xls.box2023.utils.SPUtils;

import java.util.ArrayList;

public class JiFenNetWorkUtil {
    /**
    * 单例模式
    **/
    private static JiFenNetWorkUtil mJiFenNetWorkUtil = null;
        /**
         * 构造函数私有化
         **/
        private JiFenNetWorkUtil() {
        }
        /**
         * 公有的静态函数，对外暴露获取单例对象的接口
         **/
        public static JiFenNetWorkUtil getInstance() {
            if (mJiFenNetWorkUtil == null) {
                synchronized (JiFenNetWorkUtil.class) {
                    if (mJiFenNetWorkUtil == null) {
                        mJiFenNetWorkUtil = new JiFenNetWorkUtil();
                    }
                }
            }
            return mJiFenNetWorkUtil;
        }

        public void getMyAppsAccount(RequestCallBack<ArrayList<JiFenMingXiEntity>> callBack){
            UserEntity userEntity=(UserEntity) SPUtils.getUserInfo();
            RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                    getMyAppsAccount(userEntity.getAvatar(),userEntity.getNickname(),BoxAppLication.getBaseApplication().getPackageName()), callBack);
        }

    public void getScoreExchange(String score, String typeId, String appID, String packageName, RequestCallBackTwo<DuiHuanJiBiInfoEntity> callBack) {
        UserEntity userEntity=(UserEntity) SPUtils.getUserInfo();
            RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getScoreExchange(score,typeId,appID,packageName,userEntity.getUnionId(),SPUtils.getOpenId(),userEntity.getAvatar(),userEntity.getNickname(),1+""),callBack);
    }
}
